import java.io.Serializable;
import java.util.Objects;

public class StringMessage implements Message, Serializable {
    private final String message;
    public String topic;
    public StringMessage(String message) {
        this.message = message;
    }

    public StringMessage(String topic,String message) {
        this.message = message;
        this.topic = topic;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        StringMessage that = (StringMessage) o;
        return Objects.equals(message, that.message);
    }

    @Override
    public int hashCode() {
        return Objects.hash(message);
    }

    public void getMessage() {
        System.out.println(message);;
    }

    @Override
    public String getTopic() {
        return topic;
    }

    @Override
    public String toString() {
        return  message;
    }
}
